<div class="widget_box">
    <div class="block">    
        <div class="block-title"><h2><?php echo Yii::t('site','Login');?></h2></div>    
	<div class="block-content">
	
<?php $this->widget('application.extensions.ajaxvalidationmessages.EAjaxValidationMessages',
                    array(
                       'errorCssClass'=>'clsError',
                       'errorMessageCssClass'=>'clsErrorMessage',
                       'errorSummaryCssClass'=>'clsErrorSummary')); 
					   
$userModule = Yii::app()->getModule('user'); 

$form = $this->beginWidget('CActiveForm', array(
    'id'=>'login-form',
    'enableAjaxValidation'=>true,
)); ?>

<?php echo $form->errorSummary($model); ?>

<div class="row">
    <?php echo $form->labelEx($model,'username'); ?><br>
    <?php echo $form->textField($model,'username'); ?>
    <?php echo $form->error($model,'username'); ?>
</div>
<div class="row">
    <?php echo $form->labelEx($model,'password'); ?><br>
    <?php echo $form->passwordField($model,'password'); ?>
    <?php echo $form->error($model,'password'); ?>
</div>

<div class="row">
	<?php echo CHtml::link($userModule->t("Register"), $userModule->registrationUrl); ?> | <?php echo CHtml::link($userModule->t("Lost Password?"), $userModule->recoveryUrl); ?>
</div>

<div class="row" id="update">
</div>

<div class="row">
	<?php echo  CHtml::ajaxSubmitButton('Login',
                                CHtml::normalizeUrl($userModule->loginUrl),
                                array(
								'success'=>"function(html) {
									if (html.indexOf('{')==0) {
									   jQuery('#the-form').ajaxvalidationmessages('show', html);
									}
									else {
									   jQuery('#the-form').ajaxvalidationmessages('hide');
									   window.location.reload();
									}
								 }",
								 'error'=>"function(html) {
									jQuery('#the-form').ajaxvalidationmessages('hide');
								 }",
								)); ?>
</div>

<?php $this->endWidget(); ?>

</div>
    </div>
</div>
